package com.likou;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class q234 {

    public class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
            next = null;
        }
    }


    public boolean isPalindrome(ListNode head) {
        List<Integer> list = new ArrayList<>();

        ListNode p = head;
        while (p != null) {
            list.add(p.val);
            p = p.next;
        }

        int n = list.size() / 2;
        for (int i = 0; i < n; i++) {
            if (!Objects.equals(list.get(i), list.get(list.size() - i - 1))) {
                return false;
            }
        }

        return true;
    }
}
